<?php
include "include/config.inc.php";
if(!isset($_SESSION['s_activId']))
{
  header('location:checkLogin.php');
}

$today = date("d/m/y");
$loanArray = array();
$i=0;


$selectLoan = "SELECT loan.accountId, loanId, account.accountName, value, loanAmount, fine, account.photo,
                      itemlocation.itemlocationName, loanDate, endDate, monthlyInterest, monthlyInterestRs, loanVarNo
                 FROM loan
            LEFT JOIN account ON loan.accountId = account.accountId
            LEFT JOIN itemlocation ON loan.itemlocationId = itemlocation.itemlocationId
                WHERE isSold = 'N'
                  AND isDeleted = 'N'";
if(isset($_GET['accountId']) && $_GET['accountId'] > 0)
{
  $selectLoan .= " AND loan.accountId = ".$_GET['accountId'];
}
$selectLoanRes = mysql_query($selectLoan);
if(mysql_query($selectLoan) == null)
{
	$msg = "No Record Found..";
}
while($loanRow = mysql_fetch_array($selectLoanRes))
{
  $loanArray[$i]['accountId']           = $loanRow['accountId'];
  $loanArray[$i]['loanId']              = $loanRow['loanId'];
  $loanArray[$i]['accountName']         = $loanRow['accountName'];
  $loanArray[$i]['value']               = $loanRow['value'];
  $loanArray[$i]['loanAmount']          = $loanRow['loanAmount'];
  $loanArray[$i]['fine']                = $loanRow['fine'];
  $loanArray[$i]['photo']               = $loanRow['photo'];
  $loanArray[$i]['itemlocationName']    = $loanRow['itemlocationName'];
  $loanArray[$i]['loanDate']            = date('d-m-Y',strtotime($loanRow['loanDate']));
  $loanArray[$i]['endDate']             = date('d-m-Y',strtotime($loanRow['endDate']));
  $loanArray[$i]['monthlyInterest']     = $loanRow['monthlyInterest'];
  $loanArray[$i]['monthlyInterestRs']   = $loanRow['monthlyInterestRs'];
  $loanArray[$i]['loanVarNo']           = $loanRow['loanVarNo'];
  $i++;
}
include("bottom.php");
$smarty->assign('loanArray',$loanArray);  
$smarty->display('loanList.tpl');  
?>